/*
    前三天最完美的代码
 */

package com.atguigu.day03.homework;

import java.util.Scanner;

public class HomeWork13 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入计算年份上一年的最后一天是一周的第几天:");
        int week = sc.nextInt();
        int days = 0;

        if (week > 0 && week <=7){
            System.out.println("请输入想要计算的年份:");
            int year = sc.nextInt();
            if(year > 0){
                System.out.println("请输入想要计算的月份:");
                int month = sc.nextInt();
                if(month > 0 && month <=12){
                    System.out.println("请输入想要计算的日期:");
                    int day = sc.nextInt();
                    if(month == 4 || month == 6 || month == 9 || month == 11){
                        if(day > 0 && day <30){}else{
                            System.out.println("日期格式出现错误");
                            return;
                        }
                    }else if (month == 2){
                        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
                            if(day > 0 && day <29){}else{
                                System.out.println("日期格式出现错误");
                                return;
                            }
                        }else {
                            if(day > 0 && day <28){}else{
                                System.out.println("日期格式出现错误");
                                return;
                            }
                        }
                    }else{
                        if(day > 0 && day <31){}else{
                            System.out.println("日期格式出现错误");
                            return;
                        }
                    }

            sc.close();

        switch (month) {
            case 12:
                days += 30;
            case 11:
                days += 31;
            case 10:
                days += 30;
            case 9:
                days += 31;
            case 8:
                days += 31;
            case 7:
                days += 30;
            case 6:
                days += 31;
            case 5:
                days += 30;
            case 4:
                days += 31;
            case 3:
                days += 28;
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                    days++;
                }
            case 2:
                days += 31;
            case 1:
                days += day;
                break;
            default:
                System.out.println("月份格式输入错误");
                break;
        }
        week = (week + days) % 7;

        System.out.print("今天是" + year + "年" + month + "月" + day + "日的星期");
        switch (week) {
            case 1:
                System.out.println("一");
                break;
            case 2:
                System.out.println("二");
                break;
            case 3:
                System.out.println("三");
                break;
            case 4:
                System.out.println("四");
                break;
            case 5:
                System.out.println("五");
                break;
            case 6:
                System.out.println("六");
                break;
            case 7:
                System.out.println("天");
                break;
        }
        System.out.println("也是一年的第" + days + "天");
                }else{
                    System.out.println("月份格式出错");
                }
            }else{
                System.out.println("年份格式出错");
            }
        }else {
            System.out.println("一周只有七天,你哪来的这么多天");
        }
    }

}
